package com.zj;

import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;

public enum RejectHandler {
    CallerRunsPolicy{
        @Override
        void rejectedExecution(Runnable r, ZjThreadPool executor) {
            r.run();
        }
    },
    AbortPolicy{
        @Override
        void rejectedExecution(Runnable r, ZjThreadPool executor) {
            throw new RejectedExecutionException("Task " + r.toString() +
                    " rejected from " +
                    executor.toString());
        }
    },
    DiscardPolicy{
        @Override
        void rejectedExecution(Runnable r, ZjThreadPool executor) {

        }
    };

    abstract void rejectedExecution(Runnable r, ZjThreadPool executor);

}
